package cn.jy.finanlle.controller;



import cn.jy.common.domain.financea.BaseController;
import cn.jy.common.domain.financea.ExpressAccount;
import cn.jy.common.domain.vo.ExpressAccountVo;
import cn.jy.finanlle.mapper.ExpressAccountMapper;
import cn.jy.finanlle.service.IExpressAccountService;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * financeController
 * 
 * @author ruoyi
 * @date 2024-08-22
 */
@RestController
@RequestMapping("/account")
@CrossOrigin
public class ExpressAccountController extends BaseController
{
    @Autowired
    private IExpressAccountService expressAccountService;


    /**
     * 获取finance详细信息
     */
    @RequiresPermissions("finance:account:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(expressAccountService.selectExpressAccountById(id));
    }

    /**
     * 新增finance
     */
    @RequiresPermissions("finance:account:add")
    @Log(title = "finance", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpressAccount expressAccount)
    {
        return toAjax(expressAccountService.insertExpressAccount(expressAccount));
    }

    /**
     * 修改finance
     */
    @RequiresPermissions("finance:account:edit")
    @Log(title = "finance", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpressAccount expressAccount)
    {
        return toAjax(expressAccountService.updateExpressAccount(expressAccount));
    }

    /**
     * 删除finance
     */
    @RequiresPermissions("finance:account:remove")
    @Log(title = "finance", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(expressAccountService.deleteExpressAccountByIds(ids));
    }


//    @GetMapping("/list")
//    public List<ExpressAccount> selectExpressAccountList(ExpressAccount expressAccount)
//    {
//    	return expressAccountService.selectExpressAccountList(expressAccount);
//    }

    @GetMapping("/list")
    public PageInfo<ExpressAccount> selectExpressAccountList(ExpressAccountVo expressAccountVo){
        return expressAccountService.selectExpressAccountList(expressAccountVo);
    }

    @Autowired
    private ExpressAccountMapper expressAccountMapper;

    @GetMapping("/updatestatus1")
    public int updatestatus1(@RequestParam("id") Integer id){
        return expressAccountMapper.updatestatus1(id);
    }

    @GetMapping("/updatestatus2")
    public int updatestatus2(@RequestParam("id") Integer id){
        return expressAccountMapper.updatestatus2(id);
    }
}
